<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:wh="http://java.sun.com/jsf/composite/wh"
	xmlns:p="http://primefaces.org/ui">
<h:body>
	<ui:composition template="template/template.xhtml">
		<ui:define name="content">
				<h:form>
					<p:panel>
							<h1>Game Statistics</h1>
							<p>
								Allows you to see different statistics in table form or as graph for different games. Should be used to see actual status or the evolution of the game and their actors.
							</p>
							<p:dataTable id="gameTable" var="game"
							 value="#{adminMBean.allGames()}" selectionMode="single" rowKey="#{game.name}"
							 paginatorTemplate="{RowsPerPageDropdown} {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
	                 		 rowsPerPageTemplate="10,25,50,100" paginator="true" rows="100">
							    <f:facet name="header">
						            Game Overview
						        </f:facet>
							    
							    <p:ajax event="rowSelect" listener="#{adminMBean.eventGameRowSelect}" update=":messages" />
							    
							    <p:column headerText="Name" sortBy="#{game.name}">
							        <h:outputText value="#{game.name}" />
							    </p:column>
							 
							    <p:column headerText="Created" sortBy="#{game.startDate}">
							        <h:outputText value="#{game.formattedDate()}" />
							    </p:column>
							 
							    <p:column headerText="Roundtime" sortBy="#{game.roundTime}">
							        <h:outputText value="#{game.roundTime}" />
							    </p:column>
							    
							    <p:column headerText="Number of Firms" sortBy="#{game.users.size()}">
							        <h:outputText value="#{game.users.size()}" />
							    </p:column>
							    
							    
							    <p:column  headerText="Show Statistic">
						             <p:commandButton icon="ui-icon-image" title="View Charts" action="adminGameStatisticCharts?faces-redirect=true">
						                <f:setPropertyActionListener value="#{game}" target="#{adminMBean.selectedGame}" />
						             </p:commandButton>
						             <p:commandButton icon="ui-icon-document" title="View Tables" action="adminGameStatisticTables?faces-redirect=true">
						                <f:setPropertyActionListener value="#{game}" target="#{adminMBean.selectedGame}" />
						            </p:commandButton>
						        </p:column>	
						        
							    <f:facet name="footer">
							    	<p:commandButton value="Reload Table" action="#{adminMBean.actionRefreshAllGames()}" update="gameTable" icon="ui-icon-refresh"/>
						        </f:facet>
							</p:dataTable>						
						</p:panel>
					</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>